﻿// <copyright file="AbstractModOrderingInformation.cs" company="SingularityShift">
// Copyright (c) 2009 SingularityShift.com
// </copyright>
// <author>Ben McClure</author>
// <email>ben@singularityshift.com</email>
// <date>2009-08-14</date>
// <summary>Implements most of the IModOrderingInformation functionality for other classes to use</summary>
namespace GameLib.Games
{
    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Linq;
    using System.Text;

    /// <summary>
    /// Allows an external definition of where a mod should be ordered which can be inserted into any mod list (with varying degrees of precision).
    /// </summary>
    public abstract class AbstractModOrderingInformation : IModOrderingInformation
    {
        /// <summary>
        /// An internal list of mod Ids that must be loaded before this mod if possible
        /// </summary>
        private IList<string> loadBefore = new Collection<string>();

        /// <summary>
        /// An internal list of mod Ids that must be loaded after this mod if possible
        /// </summary>
        private IList<string> loadAfter = new Collection<string>();

        /// <summary>
        /// Gets or sets the precise 0-based index for the mod. If another mod shares this index explicitely, the other values will be looked at to determine which mod to arrange first.
        /// </summary>
        public int Index
        {
            get;
            protected set;
        }

        /// <summary>
        /// <para>Gets or sets the group name indicating where this mod should be inserted. If the list being inserted into is group-aware, it should roughly place the mod within the specified group, creating the group if necessary.</para>
        /// <para>Where a new group is created in the list is not defined. Groups should be manually ordered before-hand if possible.</para>
        /// </summary>
        public string Group
        {
            get;
            protected set;
        }

        /// <summary>
        /// <para>Gets or sets the priority of this mod in its list, in its group, and/or for its specified index.</para>
        /// <para>Higher priorities come first and override lower priorities as necessary.</para>
        /// </summary>
        public int Priority
        {
            get;
            protected set;
        }

        /// <summary>
        /// <para>Gets a list of mod Ids that this mod must come before.</para>
        /// <para>Wherever possible, it will be placed before all of the mods in this list.</para>
        /// </summary>
        public IList<string> LoadBefore
        {
            get
            {
                return this.loadBefore;
            }
        }

        /// <summary>
        /// <para>Gets a list of mod Ids that this mod must come after.</para>
        /// <para>Wherever possible, it will be placed after all of the mods in this list.</para>
        /// </summary>
        public IList<string> LoadAfter
        {
            get
            {
                return this.loadAfter;
            }
        }
    }
}
